package com.ai.controller;

import groovy.util.logging.Slf4j;
import io.github.pigmesh.ai.deepseek.core.DeepSeekClient;
import io.github.pigmesh.ai.deepseek.core.chat.ChatCompletionResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * @Author liuyjy
 * @Date 2025/2/18 11:04
 * @Description: https://mp.weixin.qq.com/s/blYZjQ9Czfz-_vNwLaNfEg
 **/
@RestController
@CrossOrigin(origins = "*")
@Slf4j
@RequestMapping("/ai/DeepSeek")
public class DeepSeekController {

    @Autowired
    private DeepSeekClient deepSeekClient;

    // sse 流式返回
    @GetMapping(value = "/chat", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public Flux<ChatCompletionResponse> chat(String prompt) {
        return deepSeekClient.chatFluxCompletion(prompt);
    }


}
